package refactor.replacetypecodewithsubclasses;

public abstract class Employee {
    public static final int ENGINEER = 1;
    public static final int SALESMAN = 2;
    public static final int MANAGER = 3;
    private int monthlySalary;
    private int commission;
    private int bonus;

    public static Employee create(int type) {
        if (type == ENGINEER) {
            return new Engineer();
        }
        if (type == SALESMAN) {
            return new Salesman();
        }
        if (type == MANAGER) {
            return new Manager();
        }
        return null;
    }


    public int calcPayAmount() {
        switch (getType()) {
            case ENGINEER:
                return monthlySalary;
            case SALESMAN:
                return monthlySalary + commission;
            case MANAGER:
                return monthlySalary + bonus;
            default:
                throw new RuntimeException("Incorrect Employee");
        }
    }

    public abstract int getType();
}
